def product_except_self(arrayA):
    """计算数组中每个位置排除后的乘积"""
    n = len(arrayA)
    arrayB = [1] * n
    
    # 计算前缀乘积
    prefix = 1
    for i in range(n):
        arrayB[i] *= prefix
        prefix *= arrayA[i]
    
    # 计算后缀乘积并合并
    suffix = 1
    for i in range(n-1, -1, -1):
        arrayB[i] *= suffix
        suffix *= arrayA[i]
    
    return arrayB

def read_input(filename):
    """从文件读取输入"""
    with open(filename, 'r') as f:
        return list(map(int, f.read().split()))

def write_output(filename, arrayB):
    """将结果写入文件"""
    with open(filename, 'w') as f:
        f.write(' '.join(map(str, arrayB)))

def main():
    import sys
    if len(sys.argv) != 3:
        print("Usage: python alg.py <input_file> <output_file>")
        sys.exit(1)
    
    input_file = sys.argv[1]
    output_file = sys.argv[2]
    
    arrayA = read_input(input_file)
    arrayB = product_except_self(arrayA)
    write_output(output_file, arrayB)

if __name__ == "__main__":
    main()    